package com.jing.controller;

import com.jing.pojo.PageBean;
import com.jing.pojo.Result;
import com.jing.pojo.UserReservationInfo;
import com.jing.service.UserLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 陈书憬
 * @version 1.0
 * 2024/9/24
 */

@RestController
@RequestMapping("/log")
public class UserLogController {


    @Autowired
    private UserLogService userLogService;


    /**
     * 获取当前用户的预约记录->根据名称
     *
     * @return
     */
    @PostMapping("/roomNames")
    public Result<List<UserReservationInfo>> getRoomNames(Integer userId) {
        List<UserReservationInfo> cs = userLogService.getRoomNames(userId);
        System.out.println("成功了");
        return Result.success(cs);
    }

    /**
     * 获取用户预约记录
     * @param pageNum
     * @param pageSize
     * @param userId
     * @param names
     * @param state
     * @return
     */
    @GetMapping
    public Result<PageBean<UserReservationInfo>> getUserLogList(
            Integer pageNum,
            Integer pageSize,
            Integer userId,
            @RequestParam(required = false) String names,
            @RequestParam(required = false) String state
    ) {
        PageBean<UserReservationInfo> ul = userLogService.getUserLogList(pageNum, pageSize, userId, names, state);
        return Result.success(ul);
    }


    @GetMapping("/getAllList")
    public Result<PageBean<UserReservationInfo>> getAllUserLogList(
            Integer pageNum,
            Integer pageSize,
            @RequestParam(required = false) String names,
            @RequestParam(required = false) String state
    ) {
        PageBean<UserReservationInfo> ul = userLogService.getAllList(pageNum, pageSize, names, state);
        return Result.success(ul);
    }

}



